package com.dingreading.cloud.admin.controller;

import com.dingreading.cloud.admin.service.CmactivationCodeCommonService;
import com.dingreading.cloud.admin.service.CmactivationCodeTypeService;
import com.dingreading.cloud.common.base.R;
import com.dingreading.cloud.common.util.PageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/system/cmactivationCodeType")
@Api(tags = "总部-激活码分类管理")
public class CmactivationCodeTypeController {

    @Resource
    private CmactivationCodeCommonService cmactivationCodeCommonService;
    @Resource
    private CmactivationCodeTypeService cmactivationCodeTypeService;

    @ApiOperation(value = "分页列表")
    @PostMapping(value = "/pageList", produces = "application/json; charset=UTF-8")
    public R<Object> pageList(
            @ApiParam(value = "分页公共类") PageUtil pageUtil,
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "员工姓名") @RequestParam(value = "keyword", required = false) String keyword
    ) {
        return cmactivationCodeCommonService.pageList(pageUtil, headStaffUid, headStaffName, keyword);
    }

    @ApiOperation(value = "获取启用激活码分类信息")
    @PostMapping(value = "/getList", produces = "application/json; charset=UTF-8")
    public R<Object> getList(
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName
    ) {
        return cmactivationCodeTypeService.getList(headStaffUid, headStaffName);
    }

    @ApiOperation(value = "管理端分发激活码")
    @PostMapping(value = "/add", produces = "application/json; charset=UTF-8")
    public R<Object> add(
            @ApiParam(value = "总部员工uid") @RequestParam(value = "headStaffUid") String headStaffUid,
            @ApiParam(value = "总部员工名") @RequestParam(value = "headStaffName") String headStaffName,
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "激活码分类uid") @RequestParam(value = "activationTypeUid") String activationTypeUid,
            @ApiParam(value = "分发数量") @RequestParam(value = "codeNum") Long codeNum
    ) {
        return cmactivationCodeCommonService.add(headStaffUid, headStaffName, corpUid, storeUid, activationTypeUid, codeNum);
    }
}
